# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器，以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。

# 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时
FROM mcr.microsoft.com/dotnet/aspnet:8.0-noble AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080


# 此阶段用于生成服务项目
FROM mcr.microsoft.com/dotnet/sdk:8.0-noble AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["KWT.DRG-DIP.API/KWT.DRG-DIP.API.csproj", "KWT.DRG-DIP.API/"]
COPY ["KWT.DRG-DIP.DB/KWT.DRG-DIP.DB.csproj", "KWT.DRG-DIP.DB/"]
COPY ["KWT.DRG-DIP.DO/KWT.DRG-DIP.DO.csproj", "KWT.DRG-DIP.DO/"]
COPY ["KWT.DRG-DIP.Common/KWT.DRG-DIP.Common.csproj", "KWT.DRG-DIP.Common/"]
COPY ["KWT.DRG-DIP.DTO/KWT.DRG-DIP.DTO.csproj", "KWT.DRG-DIP.DTO/"]
COPY ["KWT.DRG-DIP.ISvc/KWT.DRG-DIP.ISvc.csproj", "KWT.DRG-DIP.ISvc/"]
COPY ["KWT.DRG-DIP.PO/KWT.DRG-DIP.PO.csproj", "KWT.DRG-DIP.PO/"]
COPY ["KWT.DRG-DIP.Mapper/KWT.DRG-DIP.Mapper.csproj", "KWT.DRG-DIP.Mapper/"]
COPY ["KWT.DRG-DIP.Svc/KWT.DRG-DIP.Svc.csproj", "KWT.DRG-DIP.Svc/"]
COPY ["KWT.DRG-DIP.Valid/KWT.DRG-DIP.Valid.csproj", "KWT.DRG-DIP.Valid/"]
RUN dotnet restore "./KWT.DRG-DIP.API/KWT.DRG-DIP.API.csproj"
COPY . .
WORKDIR "/src/KWT.DRG-DIP.API"
RUN dotnet build "./KWT.DRG-DIP.API.csproj" -c $BUILD_CONFIGURATION -o /app/build

# 此阶段用于发布要复制到最终阶段的服务项目
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./KWT.DRG-DIP.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

# 此阶段在生产中使用，或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "KWT.DRG-DIP.API.dll"]